package org.secur.eave.ui

import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.github.shadowsocks.R
import com.github.shadowsocks.databinding.ActivitySettingBinding

class SettingActivity : AppCompatActivity() {
	private lateinit var bin:ActivitySettingBinding
	override fun onCreate(savedInstanceState: Bundle?) {
		super.onCreate(savedInstanceState)
		bin = ActivitySettingBinding.inflate(layoutInflater)
		setContentView(bin.root)
	
		bin.back.setOnClickListener {
			finish()
		}
		bin.a.setOnClickListener {
			val appName = getString(R.string.app_name)
			val versionName =packageManager
				.getPackageInfo(packageName, 0).versionName
			AlertDialog.Builder(this)
				.setTitle("Information")
				.setMessage("Name: $appName\nVersion: $versionName")
				.setPositiveButton("OK", null)
				.show()
		}
		bin.constraintLayout.setOnClickListener {
			val url = "https://play.google.com/store/apps/details?id=${packageName}"
			val intent = Intent(Intent.ACTION_SEND).apply {
				type = "text/plain"
				putExtra(Intent.EXTRA_TEXT, url)
			}
			val chooserIntent = Intent.createChooser(intent, "Share via")
			startActivity(chooserIntent)
		}
	}
}